﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using RMS.Models;
using RMS.Models.DatabaseManager;

namespace RMS.Pages
{
    public partial class ChangePassword : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void UpdatePassword(object sender, EventArgs e)
        {
            UserManager userManager = new UserManager();
            string email = (string)Session["Email"];
            string oldPassword = OldPassword.Text;

            if (userManager.ValidateEmail(email))
            {
                if (userManager.ValidatePassword(oldPassword))
                {
                    Session["Password"] = NewPassword.Text;
                    userManager.ChangePassword(NewPassword.Text);
                    PasswordChanged.Text = "Password Changed Successfully.";
                }
            }
        }
    }
}